﻿package com.wicture.erp4android.ui.view;

import com.libs.zxing.CaptureActivity;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.db.sqlite.CursorUtils.FindCacheSequence;
import com.wicture.erp4android.R;
import com.wicture.erp4android.utils.MyViewUtils;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


/**
 * 回收发货箱，扫描发货箱，并解除绑定
 * @author Administrator
 *
 */
public class RecyclePage implements OnClickListener{

	Activity mActivity;
	public View mRootView;
	private Button btn_unbindSendBox;
	private Button btn_confirm;
	private Button btn_cancle;
	private String sendBoxCode;
	private EditText et_code;
	public RecyclePage(Activity mActivity){
		this.mActivity = mActivity;
		initView();
	}
	private void initView(){
		
			mRootView = View.inflate(mActivity, R.layout.recycle_layout, null);
		if(mRootView!=null){
			btn_unbindSendBox = (Button) mRootView.findViewById(R.id.btn_unbindSendBox);
			btn_confirm = (Button) mRootView.findViewById(R.id.btn_confirm);
			btn_cancle = (Button) mRootView.findViewById(R.id.btn_cancle);
			et_code = (EditText) mRootView.findViewById(R.id.et_code);
			MyViewUtils.setOnclick(this, btn_unbindSendBox, btn_confirm,btn_cancle,btn_unbindSendBox);
		}
	}
	@Override
	public void onClick(View v) {
	switch (v.getId()) {
	//打开扫描界面
	case R.id.btn_unbindSendBox:
		System.out.println("打开摄像头");
		Intent intent = new Intent(mActivity,CaptureActivity.class);
		mActivity.startActivityForResult(intent, 2);
		break;
	case R.id.btn_confirm:
		//请求网络，解除绑定
		System.out.println("确定");
		comitData();
		break;
	case R.id.btn_cancle:
		//清空条形码
		sendBoxCode = null;
		et_code.setText("");
		break;
	default:
		break;
	}
		
	} 

	/**
	 * 提交数据
	 */
	public void comitData(){
		HttpUtils http = new HttpUtils();
		
		Toast.makeText(mActivity, "解绑成功", Toast.LENGTH_SHORT).show();
		sendBoxCode = null;
	}
	
	
	/**
	 * 设置文本框条形码
	 * @param codeString
	 */
	public void setCode(String codeString){
		sendBoxCode = codeString;
		et_code.setText(sendBoxCode);
	}
}
